<template>
  <!-- 消息通知 -->
  <div class="notice-card" :style="customStyle">
    <div class="notice-item" v-for="(notice, index) in notices" :key="index">
      <span
        class="notice-type"
        :class="notice.type === 'article' ? 'article-type' : 'follow-type'"
      >
        {{ notice.type === "article" ? "【发布文章】" : "【新人关注】" }}:
      </span>
      <span class="notice-content">
        {{ notice.content }}
      </span>
      <span class="notice-time">
        {{ notice.time }}
      </span>
    </div>
  </div>
</template>
<script>
export default {
  name: "Notice",
  props: {
    customStyle: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      notices: [
        {
          type: "article",
          content: "刚刚成功发布一篇...",
          time: "1小时前",
        },
        {
          type: "follow",
          content: '刚刚有1位"小太...',
          time: "1小时前",
        },
        {
          type: "follow",
          content: '刚刚有1位"小太...',
          time: "1小时前",
        },
        {
          type: "follow",
          content: '刚刚有1位"小太...',
          time: "1小时前",
        },
        {
          type: "follow",
          content: '刚刚有1位"小太...',
          time: "1小时前",
        },
        {
          type: "article",
          content: "刚刚成功发布一篇...",
          time: "1小时前",
        },
        {
          type: "follow",
          content: '刚刚有1位"小太...',
          time: "1小时前",
        },
        {
          type: "follow",
          content: '刚刚有1位"小太...',
          time: "1小时前",
        },
      ],
    };
  },
};
</script>
<style scoped>
.notice-card {
  background: white;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-height: 224px;
  overflow-y: auto;
}

.notice-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
  line-height: 1.5;
}

.notice-item:last-child {
  border-bottom: none;
}

.notice-type {
  font-weight: bold;
  margin-right: 8px;
  white-space: nowrap;
}

.article-type {
  color: #409eff;
}

.follow-type {
  color: #fc8a3b;
}

.notice-content {
  flex: 1;
  color: #606266;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice-time {
  color: #909399;
  margin-left: 10px;
  white-space: nowrap;
}

/* 美化滚动条 */
.notice-card::-webkit-scrollbar {
  width: 6px;
}

.notice-card::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.notice-card::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 3px;
}

.notice-card::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}
</style>
